/*
///////////////////////////////////////////////////////
Filename:	DateTime.h
Version:	V1.2
Published:	2005-02-25 08:36
Author:		Hua Weidong

                R E A D   M E
**2005-02-25 08:00
1. Change DATETIME struct. 
    Add field: TenthMilliSecond

///////////////////////////////////////////////////////
*/
#ifndef ___DateTime_H___
#define ___DateTime_H___

#include	<stdint.h>
#include	<stdbool.h>

typedef struct _DATETIME{
	uint16_t year;
	uint8_t month;
	uint8_t day;
	uint8_t hour;
	uint8_t minute;
	uint8_t second;
	uint8_t tenthMilliSecond;
	} DATETIME;

extern bool IsLeapYear(uint16_t year);
extern bool SimpleIsLeapYear(uint8_t year);
extern bool IsInLeapYear(const DATETIME *datetime);
extern DATETIME* ReplaceYear(DATETIME *datetime,uint16_t year);
extern DATETIME* ReplaceMonth(DATETIME *datetime,uint8_t month);
extern DATETIME* ReplaceDay(DATETIME *datetime,uint8_t day);
extern DATETIME* ReplaceHour(DATETIME *datetime,uint8_t hour);
extern DATETIME* ReplaceMinute(DATETIME *datetime,uint8_t minute);
extern DATETIME* ReplaceSecond(DATETIME *datetime,uint8_t second);

extern DATETIME* IncMilliSecond(DATETIME *datetime,int32_t milliseconds);
extern DATETIME* IncSecond(DATETIME *datetime,int32_t seconds);
extern DATETIME* IncMinute(DATETIME *datetime,int32_t minutes);
extern DATETIME* IncHour(DATETIME *datetime,int32_t hours);
extern DATETIME* IncDay(DATETIME *datetime,int32_t days);
extern DATETIME* IncMonth(DATETIME *datetime,int32_t months);

extern DATETIME* EncodeDateTime(DATETIME *datetime,uint16_t year,uint8_t month,
	uint8_t day,uint8_t hour,uint8_t minute,uint8_t second);

extern uint8_t DaysInMonth(const DATETIME *datetime);
extern uint16_t DaysInYear(const DATETIME *datetime);

extern uint8_t DaysInAMonth(uint16_t year,uint8_t month);
extern uint16_t DaysInAYear(uint16_t year);
extern uint16_t DayOfTheYear(const DATETIME *datetime);

extern bool IsValidDateTime(const DATETIME *datetime);
extern int8_t CompareDateTime(const DATETIME *datetime1,const DATETIME *datetime2);

extern uint32_t YearsBetween(const DATETIME *ANow,const DATETIME *AThen);
extern uint32_t DaysBetween(const DATETIME *ANow,const DATETIME *AThen);
extern uint32_t HoursBetween(const DATETIME *ANow,const DATETIME *AThen);
extern uint32_t MinutesBetween(const DATETIME *ANow,const DATETIME *AThen);
extern uint32_t SecondsBetween(const DATETIME *ANow,const DATETIME *AThen);

#endif
